<!doctype html>
<html>

<head>
	<meta charset="UTF-8">
	<title>完成付款</title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link href="../css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" href="../css/style.css" />
	<link rel="stylesheet" href="../css/iconfont.css" />
	<link rel="stylesheet" href="../css/wallet.css" />
</head>

<body>
	<div class="mui-content paymentcg_content">
		<div class="fukc_top">
			<div class="fukc_weix"><!--微信支付的--> 
				<div class="iconfont icon-weixin2"></div>			
				<p>支付成功</p>
			</div>
			<div class="fukc_zhifub" style="display: none;"><!--支付宝支付的--> 
				<div class="iconfont icon-zhifubao1"></div>			
				<p>支付成功</p>
			</div>
			<div class="fukc_pribox">¥<em id='pay_money'>0.00</em></div>
			<div class="iconfont icon-huiyuan"></div>
		</div>
		<div class="fukc_djh clearfix">
			<span class="left">单据号</span>
			<span class="right" id='sn'></span>
		</div>
		<div class="fukc_xq clearfix">
			<div class="left">付款详情</div>
			<div class="right">
				<p class="clearfix">
					<Span class="pleft" id='pay_model'>微信支付</Span>
					<span class="pright"><em id='pay_model_money'>0.00</em>元</span>
				</p>
				<p class="clearfix" style="display: none;">
					<Span class="pleft">鼓励金抵现</Span>
					<span class="pright"><em id='j_pay_score'>0.00</em></span>
				</p>
				<p class="clearfix special">
					<Span class="pleft">您有一笔鼓励金</Span>
					<span class="pright"><button type="button" class="gulij_btn">领取</button></span>
				</p>
			</div>
		</div>
		<div class="qitsj_lisbox">
			<div class="bt"><img src="../images/payment_ct.jpg"></div>
			<ul class="qitsj_lis" id='item_ul'>
				<li class="clearfix">
					<div class="tjsj_img"><img src="../images/bgtu.jpg"></div>
					<div class="tjsj_info">
						<div class="tjsj_nam">
							<div class="name"></div>
							<div class="iconfont icon-new"></div>
						</div>
						<div class="tjsj_jif">鼓励金最高可抵<em>0%</em></div>
						<div class="tjsj_dzbox clearfix">
							<div class="tjsj_dz"></div>
							<div class="tjsj_jul">0km</div>
						</div>
					</div>
				</li>
			</ul>
		</div>
		<!--绑定手机号弹出框-->
		<div class="mask">
			<div class="fuk_bdsj">
				<p class="bt">绑定手机号</p>
				<p><img src="../images/bac_bdsj.jpg"></p>
				<p class="tip">绑定手机号，让您的账户更加安全</p>
				<p class="number"><input type="number" name="" id="" value="" placeholder="请输入您的手机号" /></p>
				<div class="yzm clearfix">
					<input type="text" name="" id="" value="" placeholder="请输入验证码" />
					<button type="button" class="fuk_yzmbtn">获取验证码</button>
				</div>
				<p><button type="button" class="fukc_btn">确定</button></p>
			</div>			
		</div>
		<!--鼓励金弹出框-->
		<div class="mask">
			<div class="fuk_gulijbox">
				<p class="bt">龙信云支付送鼓励金</p>
				<div class="gulij_pri"><em>1.48</em>元</div>
				<p>已存入鼓励金账户</p>
				<div class="fuk_gljbtnbox"><button type="button" class="gulijin_btn">确定</button></div>
			</div>			
		</div>
		
		
		
	</div>
	<script src="../js/mui.min.js"></script>
	<script type="text/javascript">
		mui.init()
	</script>
</body>
</html>
<script src="../js/mui.min.js"></script>
	<script type="text/javascript" src="../js/date.js"></script>

	<script type="text/javascript" src="../js/jquery.min.js"></script>
	<script type="text/javascript" src="../js/layer/layer.min.js"></script>
		<script type="text/javascript" src="../js/app.js"></script>
	<script>
    	var ua = navigator.userAgent.toLowerCase();  
	    if(ua.match(/MicroMessenger/i)=="micromessenger") {  
	    } else {  
	    	$(".js-wx").text("微信支付(仅限微信浏览器)");
	    }  
  
		$(function() {
			checkLogin(APP.web_root+"member/login.html");
			var member = JSON.parse(localStorage.getItem('member'));
			//获取商户信息
			$.ajax({
				url: APP.api_url + 'Wallet/agent_shou',
				data: {
					uid			: getUid(),
					token 		: get_token(),
					agent_id 	: getUrlParam('getmoney_uid')
				},
				//type: "post",
				success: function(data) {
					var store_info = data.data;
					$("#order_no").text(store_info['sn']);
					$("#agent_name").text(store_info['store_name']);
					$("#store_id").val(store_info['id']);
				}
			})
			$(".btn-primary").click(function() {
				$(".modal").addClass("in");
				$(".modal").show();
			})
			$(".js-m").click(function() {
				var pay_type=$(this).data("type");
				$("#cut_pay_type").val(pay_type);
				
				var act="alipay";
				var jstype="html";
				var openid=member['openid'];
				if(openid==""){
					openid=localStorage.getItem("openid");
				}
				if(pay_type==2){
					act="wechat";
					jstype="jsonp";
				}else if(pay_type==4){
					act="unionpay";
				}
				$.ajax({
					url: APP.api_url + 'Payment/'+act,
					data: {
						WIDout_trade_no	: $("#order_no").text(),
						WIDsubject		: "面对面收款",
						WIDtotal_fee	: $("#pay_money").val(),
						return_url		: APP.web_root+"member/index.html",
						WIDshow_url		: 'www',
						WIDbody			: '面对面收款授权支付',
						uid				: getUid(),
						type			: "gathering",
						user_type		: member['agent_type'],
						order_id		: $("#store_id").val(),
						token			: get_token(),
						openid			: openid,
						pay_type		: pay_type
					},
					type: "post",
					dataType:jstype,
					jsonp:'callback',  
					jsonpCallback :'jsonpCallback',
					success: function(data) {
						$("#post_sn").val($("#order_no").text()); 
						$("#post_money").val($("#pay_money").val());
						if(pay_type==2){
							callpay(data);
						}else{
							$("#callback").append(data);
						}
						if(pay_type==4){
							$("#pay_form").submit();
						}
					}
				})
			})
		function jsonpCallback(data){
			
			$("#cut_back").append(data);
		}
			//调用微信JS api 支付
		function jsApiCall(jsApiParameters) {
			WeixinJSBridge.invoke('getBrandWCPayRequest', jsApiParameters,
				function(res) {
					if(res.err_msg == "get_brand_wcpay_request:ok") {
						$("#pay_status").val(2);
						alert('支付成功');
					} else {
						$("#pay_status").val(1);
						alert('支付失败');
					}
					print_log();
				}
			);
		}

		function callpay(jsApiParameters) {
			console.log(jsApiParameters);
			if(typeof WeixinJSBridge == "undefined") {
				if(document.addEventListener) {
					document.addEventListener('WeixinJSBridgeReady', jsApiCall(jsApiParameters), false);
				} else if(document.attachEvent) {
					document.attachEvent('WeixinJSBridgeReady', jsApiCall(jsApiParameters));
					document.attachEvent('onWeixinJSBridgeReady', jsApiCall(jsApiParameters));
				}
			} else {
				jsApiCall(jsApiParameters);
			}
		}
		
		
		
		//打印日志
	function print_log(){
		$.ajax({
				url: APP.api_url + 'Wallet/add_paylog',
				data: {
					uid 		: getUid(),
					token		: get_token(),
					type		: "gathering",
					sn			: $("#order_no").text(),
					user_type	: member['agent_type'],
					pay_type	: $("#cut_pay_type").val(),
					tid			: $("#store_id").val(),
					price		: $("#pay_money").val(),
					status		: $("#pay_status").val()
				},
				//type: "post",
				success: function(data) {
					if(dat.code==200){
						alert("日志打印成功")
					}else{
						alert(data.msg);
					}
				}
			})
	}
})
	</script>